<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	  <%@include file="/res/include/base-head.jsp"%>
	  <%@include file="/res/include/jquery-easyui.jsp"%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/coupon/couponBase.js"></script>
  </head>
  <body>
  <div id="toolbar" style="padding:2px;">
    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="admin.couponBase.toAdd();">添加</a>
</div>
	<div class="easyui-layout" data-options="fit:true">
	    <div data-options="region:'center',border:false">
		    <table id="datagrid" data-options="url:'${pageContext.request.contextPath}/coupon/base/list',toolbar:'#toolbar'">
				<thead>
					<tr>
						<th data-options="field:'name',width:150,align:'center'">名称</th>
						<th data-options="field:'remark',width:300,align:'center' ">内容</th>
						<th data-options="field:'quantity',width:80,align:'center' ">发行量</th>
						<th data-options="field:'fullPrice',width:80,align:'center' ">满的金额</th>
						<th data-options="field:'minusPrice',width:80,align:'center' ">减的金额</th>
						<th data-options="field:'discount',width:80,align:'center' ">折扣</th>
						<th data-options="field:'price',width:80,align:'center' ">特价</th>
						<th data-options="field:'status',width:80,align:'center',formatter:formatStatus">状态</th>
						<th data-options="field:'days',width:80,align:'center' ">有效天数</th>
						<th data-options="field:'isQBuy',width:90,align:'center',formatter:formatIsQBuy">是否圈币兑换</th>
						<th data-options="field:'bizzType',width:100,align:'center',formatter:formatType">优惠卷类型</th>
						<th data-options="field:'strNewAt',width:130,align:'center' ">创建时间</th>
						<th data-options="field:'strExpireAtU',width:130,align:'center' ">到期时间</th>
			            <th data-options="field:'id',align:'center',width:220,formatter:formatOperation">管理操作</th>
					</tr>
				</thead>
			</table>
	  	</div>
	</div>
	<script>
		function formatOperation(value,row,index) {
			var l_html = '';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.couponBase.detail('+row.id+')">查看</a>';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.couponBase.toUpdate('+row.id+')">编辑</a>';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.couponBase.toUser('+row.id+')">已发用户</a>';
			if(row.status==2){
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.couponBase.up('+row.id+')">发行</a>';
			}else if(row.status==1){
				l_html += '<a href="javascript:;" class="table_link" style="color:red;" onclick="admin.couponBase.down('+row.id+')">删除</a>';
			}
			/* if(row.isQBuy==1){
				l_html += '<a href="javascript:;" class="table_link" style="color:red;" onclick="admin.couponBase.qBuyDown('+row.id+')">停止圈币兑换</a>';
			}else {
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.couponBase.qBuyUp('+row.id+')">开启圈币兑换</a>';
			} */
			return l_html;
		}
		function formatStatus(status) {
			var l_html = '';
			if(status==1){
				l_html="发行";
			} else if(status==2){
				l_html="停止";
			}
			return l_html;
		}
		function formatIsQBuy(isQBuy) {
			var l_html = '';
			if(isQBuy==1){
				l_html="是";
			} else if(isQBuy==2){
				l_html="否";
			}
			return l_html;
		}
		
		
		function formatType(bizzType) {
			var l_html = '';
			if(bizzType==1){
				l_html="普通优惠卷";
			} else if(bizzType==2){
				l_html="单商品优惠卷";
			} else if(bizzType==3){
				l_html="服务类目优惠卷";
			} else if(bizzType==4){
				l_html="商城类目优惠卷";
			} else if(bizzType==5){
				l_html="商城优惠卷";
			}
			return l_html;
		}
	</script>
  </body>
</html>
